package com.wf.demo.sys.pojo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.wf.demo.info.pojo.Company;
import lombok.Data;

import javax.persistence.*;
import java.time.LocalDateTime;

/**
 * 系统用户
 *
 * @author lx
 */
@Data
@Entity
@Table(name = "sys_user")
@JsonIgnoreProperties({ "handler","hibernateLazyInitializer" })
public class User {
    private static final long serialVersionUID = 1L;

    /**
     * 用户ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;

    /**
     * 用户名
     */

    private String username;

    /**
     * 密码
     */
    private String password;

    /**
     * 盐
     */
    private String salt;

    /**
     * 手机号
     */
    private String mobile;

    /**
     * 状态  0：禁用   1：正常
     */
    private Integer status;

    @ManyToOne
    @JoinColumn(name = "rid") //很多用户拥有统一角色
    private  Role role;

    @ManyToOne
    @JoinColumn(name = "cid")
    private Company company;    //对应的公司外键,很多角色对应一个公司

    /**
     * 创建时间
     */
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;
}
